#include "vnc_computer_thread.h"


VNC_ComputerThread::VNC_ComputerThread (ResultFormatter& resFmt, ADCM_Computer& adcmComputer, wstring& user,
										wstring& password, wstring& domain,bool isLocal)
										: _adcmComputer(adcmComputer), _user(user),
										_password(password), _domain(domain), _resFormatter(resFmt),_isLocal(isLocal),_exit(false)
{
}

DWORD VNC_ComputerThread::Run(LPVOID arg)
{
CM_ResultCollection *cmResult = new CM_ResultCollection();

	WMI_HResult whres;

	do
	{
		cout<<"hola mundo";
		whres = bridget_communicator::getComputersResult(_adcmComputer.getIdComputer(),
		cmResult, _user, _password, wstring(_adcmComputer.getCn()), _domain, _isLocal);

		if (FAILED(whres.getHRESULT	()))
		{
			wcout << "Error in getcomputerResult method" << endl;
			break;		
		}

		vector<WMI_Process*> vecProcess = cmResult->getProcesses().getObjects();

		vector<WMI_Process*>::iterator iter;

		for (iter = vecProcess.begin(); iter != vecProcess.end(); iter ++)
		{
			wcout << "Name: " << (*iter)->getCaption() << endl;
		}

		// cout << "Esta en el while" << endl;

	} while (!_exit);

	cout << "Salio del while" << endl;

	return NULL;

	//bridget_communicator::getDifferences(_adcmComputer.getIdComputer(), *cmDifRes);
	
	//_resFormatter.printResult(_adcmComputer, *cmRes);
	
}
